﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace mdk
{
    class SkyDome
    {
        Model model;
        Vector3 position;
        Texture2D texture;
        BasicEffect be;        

        public SkyDome()
        {
            position = Vector3.Zero;
        }

        internal void LoadContent(GraphicsDevice graphicsDevice, ContentManager content)
        {
            model = content.Load<Model>("models/skybox/skybox");
            texture = content.Load<Texture2D>("models/skybox/stars");
            be = new BasicEffect(graphicsDevice);
            be.Texture = texture;
            be.TextureEnabled = true;
        }
        


        public void Update(GameTime gameTime, Camera camera)
        {
            this.position = camera.Position;
        }

        public void Draw(GameTime gameTime, Camera camera)
        {
            foreach (ModelMesh mm in model.Meshes)
            {
                foreach (BasicEffect be in mm.Effects)
                {
                    be.Texture = texture;
                    be.TextureEnabled = true;
                    be.World = Matrix.CreateScale(1000) * Matrix.CreateRotationX(MathHelper.ToRadians(0)) * Matrix.CreateTranslation(camera.Position);
                    be.View = camera.View;
                    be.Projection = camera.Projection;
                }
                mm.Draw();
            }

        }
    }
}
